package scau.mis4.chanyulin;

import javafx.application.Application;
import javafx.geometry.Insets;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.layout.HBox;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;
import scau.mis4.chanyulin.view.SensorDisplay;

/**
 * Created by cyl on 2017/12/5.
 * 传感器图像测试类
 */
public class DisplayTest2 extends Application {

    @Override
    public void start(Stage primaryStage) throws Exception {
        SensorDisplay display = new SensorDisplay();
        Button button1 = new Button("开始");
        Button button2 = new Button("停止");
        Button button3 = new Button("0.05");
        Button button4 = new Button("0.1");
        Button button5 = new Button("0.3");
        Button button6 = new Button("0.5");
        Button button7 = new Button("1.0");
        button1.setOnAction(event -> {display.start();});
        button2.setOnAction(event -> {display.stop();});
        button3.setOnAction(event -> {display.stop();display.setRefreshSeconds(0.05);display.start();});
        button4.setOnAction(event -> {display.stop();display.setRefreshSeconds(0.1);display.start();});
        button5.setOnAction(event -> {display.stop();display.setRefreshSeconds(0.3);display.start();});
        button6.setOnAction(event -> {display.stop();display.setRefreshSeconds(0.5);display.start();});
        button7.setOnAction(event -> {display.stop();display.setRefreshSeconds(1.0);display.start();});
        HBox hBox = new HBox();
        hBox.setPadding(new Insets(5, 5, 5, 5));
        hBox.getChildren().addAll(button1, button2, button3, button4, button5, button6, button7);
        VBox vBox = new VBox(display, hBox);
        vBox.setPadding(new Insets(5, 5, 5, 5));
        Scene scene = new Scene(vBox);
        primaryStage.setScene(scene);
        primaryStage.setTitle("Sensor Display Test");
        primaryStage.show();
    }

    public static void main(String[] args) {
        Application.launch(args);
    }

}
